<template>
  <div style="margin-left: 12px">
    <div id="divSearch" ref="divSearch" style="margin-top: 30px">
      <el-form
        :inline="true"
        :model="Search"
        size="mini"
        class="demo-form-inline"
      >
        <el-form-item label="编号" prop="Search">
          <el-input v-model="Search.TempleteId" placeholder="编号" />
        </el-form-item>
        <el-form-item label="名称" prop="Search">
          <el-input v-model="Search.templeteName" placeholder="名称" />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="small"
            @click="getDataList"
            >查询</el-button
          >
          <el-button
            type="success"
            icon="el-icon-circle-plus"
            size="small"
            @click="handeAdd"
            >新增</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <div style="width: 100%">
      <el-table
        :data="DataList"
        style="width: 100%; margin-top: 0px"
        border
        @sort-change="sortChange"
        :height="tableHeight"
      >
        <el-table-column align="center" label="编号">
          <template slot-scope="scope">{{ scope.row.TempleteId }}</template>
        </el-table-column>
        <el-table-column align="center" label="名称">
          <template slot-scope="scope">{{ scope.row.templeteName }}</template>
        </el-table-column>

        <el-table-column align="center" label="建单人">
          <template slot-scope="scope">{{ scope.row.CreatedByName }}</template>
        </el-table-column>
        <el-table-column align="center" label="建单时间">
          <template slot-scope="scope">{{ scope.row.CreatedOn }}</template>
        </el-table-column>
        <el-table-column align="center" label="修改人">
          <template slot-scope="scope">{{ scope.row.ModifiedByName }}</template>
        </el-table-column> <el-table-column align="center" label="修改时间">
          <template slot-scope="scope">{{ scope.row.ModifyedOn }}</template>
        </el-table-column>
        <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <el-button type="primary" size="small" @click="handleEdit(scope)"
              >修改</el-button
            >
            <el-button type="danger" size="small" @click="handleDelete(scope)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>

    <el-pagination
      background
      layout="sizes, prev, pager, next,total"
      :page-size="Search.pageSize"
      :total="Search.total"
      @current-change="pageChange"
    />
  </div>
</template>

<script>
import path from "path";
import { deepClone } from "@/utils";
import {getDataList,DelettempleteForm} from "@/api/System";
import elementIcons from "../icons/element-icons";
import vAccountOpen from '../Common/AccountOpen';
import vDepOpen from "../Common/DepOpen";
// 默认的编辑字段
const defaultObject = {};

export default {
  name: "templeteList",

  components: {
    vAccountOpen,
    vDepOpen,
  },

  data() {
    return {
      tableHeight:null,
      isEdit: false,
      EditObj: [],
      DataList: [], //队列的列表 在el-table中用
      dialogVisible: false,
      dialogTableVisible: false,
      Search: {
        // 查询条件
        total: 0, // 总记录数
        pageSize: 10, // 一页显示的记录数
        page: 1, // /当前页码
        RNO: "006", // 表编号  根据Controller中对应的表编号
        jsWhere: "", // 自定义条件
      },
      dialogFormVisible: false,
      dialogDeptVisible: false,
      multipleTable: [],
      DeptTable:[],
    };
  },
  computed: {
    routesData() {
      return this.routes;
    },
  },
  created() {
    // Mock: get all routes and roles list from server

    this.getDataList();
  },
  mounted() {
    setTimeout(() => {
      this.tableHeight = window.innerHeight - 220 + "px";
    });
  },
  methods: {
    pageChange(page) {
      // 翻页
      this.Search.page = page;

      this.getDataList();
    },
    async getDataList() {
      // 获取列表数据，通用
      const res = await getDataList({ data: JSON.stringify(this.Search) });
      var temp=res.data.Table
    
      this.DataList = temp; //将data 中的数据放到DataList中
      this.Search.total = res.data.Table1[0].RecordCount;
    },
    sortChange: function (column) {
      // column, prop, order,排序，通用

      this.Search.sort = column.prop + " " + column.order;
      this.getDataList();
    },
    async handeAdd() {
      // 新建
         
   let routeUrl = this.$router.push({
        path: "/System/editTemplete",
        query: { billID:"", IsPostBack: false },
      });
      window.open(routeUrl.href, "_top");
    },
    async handleEdit(scope) {
    
    let routeUrl = this.$router.push({
        path: "/System/editTemplete",
        query: { billID: scope.row.TempleteId, IsPostBack: false },
      });
      window.open(routeUrl.href, "_top");

      this.inputName = scope.row.TempleteId;

     },
     // async handleDelete({ $index, row }) {
    //   //删除
    //   this.$confirm("确定删除该记录吗?", "警告", {
    //     confirmButtonText: "确认",
    //     cancelButtonText: "取消",
    //     type: "warning",
    //   }).then(async () => {
    //     await DelettempleteForm({
    //       TempleteId: row.TempleteId,
    //     });
    //     this.DataList.splice($index, 1);
    //     if (result.code === 20000) {
    //       this.dialogVisible = false;
    //       this.$notify({
    //         title: "Success",
    //         dangerouslyUseHTMLString: true,
    //         message: result.msg,
    //         type: "success",
    //       });
    //     } else {
    //       this.$notify({
    //         title: "error",
    //         dangerouslyUseHTMLString: true,
    //         message: result.msg,
    //         type: "error",
    //       });
    //     }
    //   });
    // }
    
  }
};
</script>

<style lang="scss" scoped>
.app-container {
  .EditObjs-table {
    margin-top: 30px;
  }

  .permission-tree {
    margin-bottom: 5px;
  }

  /* 解决element-ui的table表格控件表头与内容列不对齐问题 */
  .el-table {
    display: table-cell !important;
    text-align: center;
  }
}
.customWidth {
  width: 80%;
  height: 860px;
}
</style>
